$(function () {
    $("#loginBtn").on("click",function () {
        var username=$("#username").val()
            password=$("#password").val()
            if(!$.trim(username))  {
                mui.toast("用户名不能为空")
                return
            }
            if(!$.trim(password))  {
                mui.toast("密码不能为空")
                return
            }
       $.ajax({
           
            type: 'post',
            url: '/user/login',
            data: {
                username,
                password,
            },
            dataType: 'json',
            success: function (res) {
                console.log( res);
             if(res.error==403) {
                 mui.toast(res.message)
             }
             if(res.success) {
               if(location.search.indexOf("reUrl")>-1) {
             var url=location.search.split("reUrl=")[1]
                location.href=url
               }else {
                location.href="./user.html"  
               }
             }
            }
        })  
    }) 
})